﻿using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using FluentNHibernate.Cfg;
using FluentNHibernate.Cfg.Db;
using FluentNHibernate.Mapping;
using NHibernate.Tool.hbm2ddl;

namespace chore.Domain
{
    public class Chore
    {
        public virtual long Id { get; set; }
        public virtual string Title { get; set; }
        public virtual string Description { get; set; }
        public virtual User Owner { get; set; }
        public virtual IList<Assignment> Assignments { get; set; }
    }

    public class ChoreMap : ClassMap<Chore>
    {
        public ChoreMap()
        {
            Id(c => c.Id).GeneratedBy.Identity();
            Map(c => c.Title);
            Map(c => c.Description);
            
            HasMany(c => c.Assignments)
                .AsBag()
                .Cascade.All();

            References(c => c.Owner);
        }
    }
}
